from selenium.webdriver.common.by import By
from project_page.base_page import BasePage
from project_page.contact_page import ContactPage
from project_page.wework_page import WeworkPage


class AddMemberPage(WeworkPage):
    # 元素抽离
    Input_Username= (By.ID, "username")
    Input_acctid = (By.ID, "memberAdd_acctid")
    Input_phonenumber = (By.ID,"memberAdd_phone")
    Click_save = ((By.CSS_SELECTOR,".js_btn_save"))

    #跳转到通讯录页面的功能
    def add_member(self,name,codeid,phonenumber):
        #第一版未封装
        # self.driver.find_element(By.ID, "username").send_keys(name)
        # self.driver.find_element(By.ID, "memberAdd_acctid").send_keys(codeid)
        # self.driver.find_element(By.ID,"memberAdd_phone").send_keys(phonenumber)
        # self.driver.find_element(By.CSS_SELECTOR,".js_btn_save").click()
        self.find(self.Input_Username).send_keys(name)
        self.find(self.Input_acctid).send_keys(codeid)
        self.find(self.Input_phonenumber).send_keys(phonenumber)
        self.find(self.Click_save).click()
        return ContactPage(self.driver)

    def add_member_fail(self,name,codeid,phonenumber):
        self.find(self.Input_Username).send_keys(name)
        self.find(self.Input_acctid).send_keys(codeid)
        self.find(self.Input_phonenumber).send_keys(phonenumber)
        self.find(self.Click_save).click()
        return ContactPage(self.driver)